package com.erification.web.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.erification.web.dao.CelephoneDao;
import com.erification.web.dao.TrueNameDao;
import com.erification.web.model.Celephone;
import com.erification.web.service.CelephoneService;

@Service("celephoneService")
public class CelephoneServiceImpl implements CelephoneService {
	@Resource
	private CelephoneDao celephoneDao;
	@Override
	public void saveCelephone(Celephone cele) {
		celephoneDao.save(cele);
	}

	@Override
	public void modifyCelephone(long user_id, Celephone celephone, String newCele) {
		List<Celephone> list = celephoneDao.getAll(user_id);
		for(Celephone cele : list){
			if(cele.getCelephone().equals(celephone.getCelephone())){
				cele.setCelephone(newCele);
				celephoneDao.update(cele);
			}
		}
	}

	@Override
	public void deleteCelephone(long id) {
		celephoneDao.delete(id);
	}

	@Override
	public List<Celephone> getAll(long user_id) {
		return celephoneDao.getAll(user_id);
	}

	@Override
	public Celephone get(long id) {
		return celephoneDao.getCelephoneById(id);
	}

}
